package com.iteasy.manage.service.impl;

import org.iteasy.framework.base.BaseServiceImpl;
import org.iteasy.framework.commons.Constent;
import com.iteasy.manage.dao.UserDao;
import com.iteasy.manage.entity.User;
import com.iteasy.manage.service.UserService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by bo.chen on 2020/04/22 16:40:05
 */
@Service
public class UserServiceImpl extends BaseServiceImpl<UserDao,User> implements UserService {

    @Override
    @Cacheable(Constent.CacheName.USERS)
    public List<User> users() {
        return this.findAll();
    }

    @Override
    public UserDetails loadUserByUsername(String username) {
        org.springframework.security.core.userdetails.User user = new org.springframework.security.core.userdetails.User(username,
            "123456",
            AuthorityUtils.commaSeparatedStringToAuthorityList("admin"));
        return user;
    }
}
